import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { HttpRouterService } from '../../service/http-router.service';
import { HttpService } from '../../service/http.service';
import { StorageService } from '../../service/storage.service';
import * as _ from 'underscore';

@Component({
  selector: 'app-personal',
  templateUrl: './personal.component.html',
  styleUrls: ['./personal.component.less']
})
export class PersonalComponent implements OnInit {

  public isLogIn = '';
  public showMessage = false;
  public user = [];
  public certification= false;

  constructor(
              private _http: HttpService,
              private _router: Router,
              private _activatedRoute: ActivatedRoute,
              private _storage: StorageService,
              private _httpRouter: HttpRouterService
  ) { }

  ngOnInit() {

    this.isLogIn = this._storage.getSession('userId');
    if (this.isLogIn) {
      this.showMessage = true;
      this.user = JSON.parse(this._storage.getSession('user'));
      if (this.user['realname']) {
        this.certification = true;
      }
    }

  }

  logOut($event) {
    this._storage.removeSession('userId');
    this._storage.removeSession('user');
    this._storage.removeLocal('token');
    this._router.navigate(['/attache/login']);
  }


}
